﻿using System;
using System.Web.Mvc;
using System.Web.Routing;
using iHouse.Web.Infrastructure;
using iHouse.Model.Data;
using System.Web.Http;
using Microsoft.Practices.Unity;

namespace iHouse.Web
{
    // Note: For instructions on enabling IIS6 or IIS7 classic mode, 
    // visit http://go.microsoft.com/?LinkId=9394801

    public class MvcApplication : System.Web.HttpApplication
    {
        public static void RegisterServices()
        {
            var container = new UnityContainer();
            GlobalConfiguration.Configuration.DependencyResolver = new UnityResolver(container);
            ControllerBuilder.Current.SetControllerFactory(new UnityControllerFactory(container));

            ModelBinders.Binders.Add(typeof(Album), new AlbumBinder());
        }

        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(ApiRoutes.RegisterRoutes);
            Routes.RegisterRoutes(RouteTable.Routes);
            RegisterServices();

            AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);

            //new DataBaseSetup().Execute();
        }
    }
}